/*********************************
File name:  ESS1-10_cntry_analysis.do
DATE:		3/2024
INPUT: 		ESS1-10_modified.dta 
LOG FILE:   ESS1-10_cntry_analysis.log
AUTHOR:     Odelia Oshri, Orit Kedar, Lotem Halevy
*********************************/

use "C:\Users\User\Documents\ESS1-10_modified.dta", clear
capture log using "indiv_analysis.log", replace
cd "C:\Users\User\Desktop\Figures"
set more off

/*PART 1: CLEAN DATA*/

* GENDER
rename gndr male

* GENERATE NUMERICAL VARIABLE FOR COUNTRY 
egen country = group(cntry)              
label define country 1 "AT" 2 "BE" 3 "CH" 4 "DE" ///
5 "DK" 6 "ES" 7 "FI" 8 "FR" 9 "GB" 10 "GR" 11 "IE" ///
12 "IS" 13 "IT" 14 "LU" 15 "NL" 16 "NO" 17 "PT" 18 "SE" , replace
label values country country

/* UNEMPLOYMENT: (uemp3m) Have you ever been unemployed and seeking work for a period of more than three months?  */
                
tab uemp3m, nol
drop if uemp3m>2
recode uemp3m 2=0 1=1
rename uemp3m unemp3
tab unemp3 

* MEMBER OF TRADE UNION 
tab mbtru
drop if mbtru>3
* 1: yes, currently, 2: yes, previously, 3: No*
tab mbtru, nol
gen um=.
replace um=1 if (mbtru==1)
replace um=0 if (mbtru==2 | mbtru==3) /*Rs' are non uniunized*/
tab um

* 1-DIGIT ISCO OCCUPATION 
gen  occupation=.   
replace occupation=1 if (iscoco<=1999&iscoco>=1000) | (isco08<=1999&isco08>=1000)
replace occupation=2 if (iscoco<=2999&iscoco>=2000) | (isco08<=2999&isco08>=2000)
replace occupation=3 if (iscoco<=3999&iscoco>=3000) | (isco08<=3999&isco08>=3000)
replace occupation=4 if (iscoco<=4999&iscoco>=4000) | (isco08<=4999&isco08>=4000)
replace occupation=5 if (iscoco<=5999&iscoco>=5000) | (isco08<=5999&isco08>=5000)
replace occupation=6 if (iscoco<=6999&iscoco>=6000) | (isco08<=6999&isco08>=6000)
replace occupation=7 if (iscoco<=7999&iscoco>=7000) | (isco08<=7999&isco08>=7000)
replace occupation=8 if (iscoco<=8999&iscoco>=8000) | (isco08<=8999&isco08>=8000)
replace occupation=9 if (iscoco<=9999&iscoco>=9000) | (isco08<=9999&isco08>=9000)
replace occupation=0 if iscoco==100 |  isco08<1000
label define occupation 1 " Legislators, senior officials and managers" ///
2 "Professionals" 3 " Technicians and associate professionals" 4 "Clerks " ///
5 "Service workers and shop and market sales workers" 6 "Skilled agricultural and fishery workers" ///
7 "Craft and related trades workers" 8 " Plant and machine operators and assemblers" ///
9 "Elementary occupations" 0 "Armed forces", replace
label values occupation occupation 
ta occupation /*reported in the paper : armed forces: .37%; skilled agriculture: 3.32%*/

/* Communication and manual dexterity indicators:
   values are taken from D'Amuri et al. (2014). The authors lump the O*Net
   values for the intensity of 78 tasks for the 339 occupations identified by the 
   Standard Occupation Classification (SOC) into 5 broader categories: 
   communication, mental, complex, manual and routine. They then convert each 
   of the five broad skill 'indicators' into a percentile by sector, describing 
   the particular skill intensity of the occupation compared to others. Once 
   each of the 339 occupations is assigned a percentile score D'Amuri et al. 
   lump occupations to twenty one occupational categories according to the 
   ISCO classification of occupations. The percentile score of each such category 
   is a weighted average of the scores of the relevant original occupations where 
   the weights are the proportion of the US population in each of the 339 ISCO 
   occupations according to the 2000 US Census. Lastly, we collapse 
   D'Amuri et al.s twenty-one occupational categories into ten sectors using
   a broader ISCO sector classification whereby the skill percentile score of 
   each sector is the simple average of the occupational categories that make up
   the sector.*/
gen communication=.
replace communication=85.45 if occupation==1
replace communication=69.46 if occupation==2
replace communication=67.42 if occupation==3
replace communication=70.18 if occupation==4
replace communication=64.46 if occupation==5
replace communication=18.10 if occupation==7
replace communication=21.11 if occupation==8
replace communication=29.86 if occupation==9

gen manual=.
replace manual=21.75 if occupation==1
replace manual=38.14 if occupation==2
replace manual=37.83 if occupation==3
replace manual=29.20 if occupation==4
replace manual=38.61 if occupation==5
replace manual=75.32 if occupation==7
replace manual=78.23 if occupation==8
replace manual=71.19 if occupation==9

gen routine=.
replace routine=48.75 if occupation==1
replace routine=50.40 if occupation==2
replace routine=49.35 if occupation==3
replace routine=26.34 if occupation==4
replace routine=33.01 if occupation==5
replace routine=73.68 if occupation==7
replace routine=77.43 if occupation==8
replace routine=57.30 if occupation==9

pwcorr routine manual,sig /*reported in the paper, ft#2*/
pwcorr manual communication, sig/*reported in the paper*/
gen comm=communication/100
gen man=manual/100


/* Categorizing countries with RR and without RR: 
    we exclude countries where less than 1% of voters reported voting for RR parties*/
   
* COUNTRIES WITH RR IN 2002 (ESS1) 
tab prtyfam_rr cntry if essround==1, col 
generate rress1=.
replace rress1=1 if cntry=="AT" & essround==1
replace rress1=1 if cntry=="BE" & essround==1
replace rress1=1 if cntry=="CH" & essround==1
replace rress1=1 if cntry=="DK" & essround==1
replace rress1=1 if cntry=="FR" & essround==1
replace rress1=1 if cntry=="IT" & essround==1
replace rress1=1 if cntry=="NL" & essround==1
replace rress1=1 if cntry=="NO" & essround==1

* COUNTRIES WITH RR IN 2004 (ESS2) 
tab prtyfam_rr cntry if essround==2, col
generate rress2=.
replace rress2=1 if cntry=="AT" & essround==2
replace rress2=1 if cntry=="BE" & essround==2
replace rress2=1 if cntry=="CH" & essround==2
replace rress2=1 if cntry=="DK" & essround==2
replace rress2=1 if cntry=="FR" & essround==2
replace rress2=1 if cntry=="GR" & essround==2
replace rress2=1 if cntry=="IS" & essround==2
replace rress2=1 if cntry=="NL" & essround==2
replace rress2=1 if cntry=="NO" & essround==2

* COUNTRIES WITH RR IN 2006 (ESS3) 
tab prtyfam_rr cntry if essround==3, col 
generate rress3=.
replace rress3=1 if cntry=="AT" & essround==3
replace rress3=1 if cntry=="BE" & essround==3
replace rress3=1 if cntry=="CH" & essround==3
replace rress3=1 if cntry=="DK" & essround==3
replace rress3=1 if cntry=="FR" & essround==3
replace rress3=1 if cntry=="NL" & essround==3
replace rress3=1 if cntry=="NO" & essround==3

* COUNTRIES WITH RR IN 2008 (ESS4) 
tab prtyfam_rr cntry if essround==4, col
generate rress4=.
replace rress4=1 if cntry=="BE" & essround==4
replace rress4=1 if cntry=="CH" & essround==4
replace rress4=1 if cntry=="DK" & essround==4
replace rress4=1 if cntry=="FI" & essround==4
replace rress4=1 if cntry=="FR" & essround==4
replace rress4=1 if cntry=="GR" & essround==4
replace rress2=1 if cntry=="NL" & essround==4
replace rress2=1 if cntry=="NO" & essround==4

* COUNTRIES WITH RR IN 2010 (ESS5) 
tab prtyfam_rr cntry if essround==5, col
generate rress5=.
replace rress5=1 if cntry=="BE" & essround==5
replace rress5=1 if cntry=="CH" & essround==5
replace rress5=1 if cntry=="DK" & essround==5
replace rress5=1 if cntry=="FI" & essround==5
replace rress5=1 if cntry=="FR" & essround==5
replace rress5=1 if cntry=="GR" & essround==5
replace rress5=1 if cntry=="NL" & essround==5
replace rress5=1 if cntry=="NO" & essround==5
replace rress5=1 if cntry=="SE" & essround==5

* COUNTRIES WITH RR IN 2012 (ESS6) 
tab prtyfam_rr cntry if essround==6, col
generate rress6=.
replace rress6=1 if cntry=="BE" & essround==6
replace rress6=1 if cntry=="CH" & essround==6
replace rress6=1 if cntry=="DK" & essround==6
replace rress6=1 if cntry=="FI" & essround==6
replace rress6=1 if cntry=="FR" & essround==6
replace rress6=1 if cntry=="IS" & essround==6
replace rress6=1 if cntry=="IT" & essround==6
replace rress6=1 if cntry=="NL" & essround==6
replace rress6=1 if cntry=="NO" & essround==6
replace rress6=1 if cntry=="SE" & essround==6

* COUNTRIES WITH RR IN 2014 (ESS7) 
tab prtyfam_rr cntry if essround==7, col
generate rress7=.
replace rress7=1 if cntry=="BE" & essround==7
replace rress7=1 if cntry=="CH" & essround==7
replace rress7=1 if cntry=="DK" & essround==7
replace rress7=1 if cntry=="FI" & essround==7
replace rress7=1 if cntry=="FR" & essround==7 
replace rress7=1 if cntry=="NL" & essround==7
replace rress7=1 if cntry=="NO" & essround==7
replace rress7=1 if cntry=="SE" & essround==7

* COUNTRIES WITH RR IN 2016 (ESS8) 
tab prtyfam_rr cntry if essround==8, col
generate rress8=.
replace rress8=1 if cntry=="AT" & essround==8
replace rress8=1 if cntry=="BE" & essround==8
replace rress8=1 if cntry=="CH" & essround==8
replace rress8=1 if cntry=="FI" & essround==8
replace rress8=1 if cntry=="FR" & essround==8
replace rress8=1 if cntry=="GB" & essround==8
replace rress8=1 if cntry=="IS" & essround==8
replace rress8=1 if cntry=="NL" & essround==8
replace rress8=1 if cntry=="IT" & essround==8
replace rress8=1 if cntry=="NO" & essround==8
replace rress8=1 if cntry=="NL" & essround==8
replace rress8=1 if cntry=="SE" & essround==8

* COUNTRIES WITH RR IN 2018 (ESS9) 
tab prtyfam_rr cntry if essround==9, col
generate rress9=.
replace rress9=1 if cntry=="AT" & essround==9
replace rress9=1 if cntry=="BE" & essround==9
replace rress9=1 if cntry=="CH" & essround==9
replace rress9=1 if cntry=="DK" & essround==9
replace rress9=1 if cntry=="FI" & essround==9
replace rress9=1 if cntry=="FR" & essround==9
replace rress9=1 if cntry=="IS" & essround==9
replace rress9=1 if cntry=="NL" & essround==9
replace rress9=1 if cntry=="IT" & essround==9
replace rress9=1 if cntry=="NO" & essround==9
replace rress9=1 if cntry=="NL" & essround==9
replace rress9=1 if cntry=="SE" & essround==9

* COUNTRIES WITH RR IN 2020 (ESS10) 
tab prtyfam_rr cntry if essround==10, col
generate rress10=.
replace rress10=1 if cntry=="AT" & essround==10
replace rress10=1 if cntry=="BE" & essround==10
replace rress10=1 if cntry=="CH" & essround==10
replace rress10=1 if cntry=="DE" & essround==10
replace rress10=1 if cntry=="FI" & essround==10
replace rress10=1 if cntry=="GR" & essround==10
replace rress10=1 if cntry=="IS" & essround==10
replace rress10=1 if cntry=="PT" & essround==10
replace rress10=1 if cntry=="FR" & essround==10
replace rress10=1 if cntry=="NL" & essround==10
replace rress10=1 if cntry=="NO" & essround==10
replace rress10=1 if cntry=="NL" & essround==10
replace rress10=1 if cntry=="SE" & essround==10

/* (1)
* =====================================
  =    L-R LOCATION OF MAIN LEFT PARTY 
  =    IN EVERY CNTRYEAR (CHES DATA)*
* =====================================

LIST OF MAIN SD PARTIES PER COUNTRY:
AT-SPO
BE-SOCIALIST PARTY(PS)
DE-SPD
DK-SOCIAL DEMOCRATS (SD)
ES-PSOE
FI-SDP
FR-PS
GB-LABOUR
GR-PASOK
IE-LABOUR
IT-DEMOCRATS OF THE LEFT (DS)
LU-LSAP
NL-PvdA
PT-SOCIALIST PARTY (PS)
SE-SAP 
CH -SP/PS
NO - LABOUR/SV */
* for each cntry-year we apply lrecon of either the same year or the preceding CHES wave (in cases where CHES was not run that year).  
gen lreconL=.

replace lreconL=3.44 if cntry=="AT" & year==2002 /*CHES02*/
replace lreconL=3.44 if cntry=="AT" & year==2004 /*CHES02*/
replace lreconL=2.83 if cntry=="AT" & year==2006 /*CHES06*/
replace lreconL=2.83 if cntry=="AT" & year==2008 /*CHES06*/
replace lreconL=2.64 if cntry=="AT" & year==2010 /*CHES10*/
replace lreconL=2.64 if cntry=="AT" & year==2012 /*CHES10*/
replace lreconL=2.8  if cntry=="AT" & year==2014 /*CHES14*/
replace lreconL=2.8  if cntry=="AT" & year==2016 /*CHES14*/
replace lreconL=2.8  if cntry=="AT" & year==2018 /*CHES14*/
replace lreconL=3.6  if cntry=="AT" & year==2020 /*CHES19*/

replace lreconL=2.5  if cntry=="BE" & year==2002 /*CHES02*/
replace lreconL=2.5  if cntry=="BE" & year==2004 /*CHES02*/
replace lreconL=3.17 if cntry=="BE" & year==2006 /*CHES06*/
replace lreconL=3.17 if cntry=="BE" & year==2008 /*CHES06*/
replace lreconL=2.57 if cntry=="BE" & year==2010 /*CHES10*/
replace lreconL=2.57 if cntry=="BE" & year==2012 /*CHES10*/
replace lreconL=2.4  if cntry=="BE" & year==2014 /*CHES14*/
replace lreconL=2.4  if cntry=="BE" & year==2016 /*CHES14*/
replace lreconL=2.4  if cntry=="BE" & year==2018 /*CHES14*/
replace lreconL=2.25 if cntry=="BE" & year==2020 /*CHES19*/

replace lreconL=3.57 if cntry=="DE" & year==2002 /*CHES02*/
replace lreconL=3.57 if cntry=="DE" & year==2004 /*CHES02*/
replace lreconL=3.36 if cntry=="DE" & year==2006 /*CHES06*/
replace lreconL=3.36 if cntry=="DE" & year==2008 /*CHES06*/
replace lreconL=3    if cntry=="DE" & year==2010 /*CHES10*/ 
replace lreconL=3    if cntry=="DE" & year==2012 /*CHES10*/
replace lreconL=3.5  if cntry=="DE" & year==2014 /*CHES14*/ 
replace lreconL=3.5  if cntry=="DE" & year==2016 /*CHES14*/
replace lreconL=3.5  if cntry=="DE" & year==2018 /*CHES14*/ 
replace lreconL=3.71 if cntry=="DE" & year==2020 /*CHES19*/

replace lreconL=2    if cntry=="DK" & year==2002 /*CHES02*/
replace lreconL=2    if cntry=="DK" & year==2004 /*CHES02*/
replace lreconL=2.25 if cntry=="DK" & year==2006 /*CHES06*/
replace lreconL=2.25 if cntry=="DK" & year==2008 /*CHES06*/
replace lreconL=2.27 if cntry=="DK" & year==2010 /*CHES10*/
replace lreconL=2.27 if cntry=="DK" & year==2012 /*CHES10*/
replace lreconL=2.3  if cntry=="DK" & year==2014 /*CHES14*/
replace lreconL=2.3  if cntry=="DK" & year==2016 /*CHES14*/
replace lreconL=.    if cntry=="DK" & year==2018 /*CHES14*/
replace lreconL=.    if cntry=="DK" & year==2020 /*CHES19*/

replace lreconL=4.23 if cntry=="ES" & year==2002 /*CHES02*/
replace lreconL=4.23 if cntry=="ES" & year==2004 /*CHES02*/
replace lreconL=3.92 if cntry=="ES" & year==2006 /*CHES06*/
replace lreconL=3.92 if cntry=="ES" & year==2008 /*CHES06*/
replace lreconL=3.5  if cntry=="ES" & year==2010 /*CHES10*/
replace lreconL=3.5  if cntry=="ES" & year==2012 /*CHES10*/
replace lreconL=4.11 if cntry=="ES" & year==2014 /*CHES14*/
replace lreconL=4.11 if cntry=="ES" & year==2016 /*CHES14*/
replace lreconL=4.11 if cntry=="ES" & year==2018 /*CHES14*/
replace lreconL=3.8  if cntry=="ES" & year==2020 /*CHES19*/

replace lreconL=3.89 if cntry=="FI" & year==2002 /*CHES02*/
replace lreconL=3.89 if cntry=="FI" & year==2004 /*CHES02*/
replace lreconL=3    if cntry=="FI" & year==2006 /*CHES06*/
replace lreconL=3    if cntry=="FI" & year==2008 /*CHES06*/
replace lreconL=3.6  if cntry=="FI" & year==2010 /*CHES10*/
replace lreconL=3.6  if cntry=="FI" & year==2012 /*CHES10*/
replace lreconL=3.44 if cntry=="FI" & year==2014 /*CHES14*/
replace lreconL=3.44 if cntry=="FI" & year==2016 /*CHES14*/
replace lreconL=3.44 if cntry=="FI" & year==2018 /*CHES14*/
replace lreconL=3.21 if cntry=="FI" & year==2020 /*CHES19*/

replace lreconL=4.08 if cntry=="FR" & year==2002 /*CHES02*/
replace lreconL=4.08 if cntry=="FR" & year==2004 /*CHES02*/
replace lreconL=2.13 if cntry=="FR" & year==2006 /*CHES06*/
replace lreconL=2.13 if cntry=="FR" & year==2008 /*CHES06*/
replace lreconL=2.44 if cntry=="FR" & year==2010 /*CHES10*/
replace lreconL=2.44 if cntry=="FR" & year==2012 /*CHES10*/
replace lreconL=3.83 if cntry=="FR" & year==2014 /*CHES14*/
replace lreconL=3.83 if cntry=="FR" & year==2016 /*CHES14*/
replace lreconL=3.83 if cntry=="FR" & year==2018 /*CHES14*/
replace lreconL=3.12 if cntry=="FR" & year==2020 /*CHES19*/

replace lreconL=5.28 if cntry=="GB" & year==2002 /*CHES02*/
replace lreconL=5.28 if cntry=="GB" & year==2004 /*CHES02*/
replace lreconL=4.44 if cntry=="GB" & year==2006 /*CHES06*/
replace lreconL=4.44 if cntry=="GB" & year==2008 /*CHES06*/
replace lreconL=4    if cntry=="GB" & year==2010 /*CHES10*/
replace lreconL=4    if cntry=="GB" & year==2012 /*CHES10*/
replace lreconL=3.86 if cntry=="GB" & year==2014 /*CHES14*/
replace lreconL=3.86 if cntry=="GB" & year==2016 /*CHES14*/
replace lreconL=3.86 if cntry=="GB" & year==2018 /*CHES14*/
replace lreconL=1.94 if cntry=="GB" & year==2020 /*CHES19*/

replace lreconL=4.64 if cntry=="GR" & year==2002 /*CHES02*/
replace lreconL=4.64 if cntry=="GR" & year==2004 /*CHES02*/
replace lreconL=4.22 if cntry=="GR" & year==2006 /*CHES06*/
replace lreconL=4.22 if cntry=="GR" & year==2008 /*CHES06*/
replace lreconL=5.64 if cntry=="GR" & year==2010 /*CHES10*/
replace lreconL=5.64 if cntry=="GR" & year==2012 /*CHES10*/
replace lreconL=5.44 if cntry=="GR" & year==2014 /*CHES14*/
replace lreconL=5.44 if cntry=="GR" & year==2016 /*CHES14*/
replace lreconL=5.44 if cntry=="GR" & year==2018 /*CHES14*/
replace lreconL=4.22 if cntry=="GR" & year==2020 /*CHES19*/

replace lreconL=3    if cntry=="IE" & year==2002 /*CHES02*/
replace lreconL=3    if cntry=="IE" & year==2004 /*CHES02*/
replace lreconL=3.8  if cntry=="IE" & year==2006 /*CHES06*/
replace lreconL=3.8  if cntry=="IE" & year==2008 /*CHES06*/
replace lreconL=3.5  if cntry=="IE" & year==2010 /*CHES10*/
replace lreconL=3.5  if cntry=="IE" & year==2012 /*CHES10*/
replace lreconL=4.13 if cntry=="IE" & year==2014 /*CHES14*/
replace lreconL=4.13 if cntry=="IE" & year==2016 /*CHES14*/
replace lreconL=4.13 if cntry=="IE" & year==2018 /*CHES14*/
replace lreconL=3.57 if cntry=="IE" & year==2020 /*CHES19*/

replace lreconL=3.42 if cntry=="IT" & year==2002 /*CHES02*/
replace lreconL=3.42 if cntry=="IT" & year==2004 /*CHES02*/
replace lreconL=3    if cntry=="IT" & year==2006 /*CHES06*/
replace lreconL=3    if cntry=="IT" & year==2008 /*CHES06*/
replace lreconL=.    if cntry=="IT" & year==2010 /*CHES10*/
replace lreconL=.    if cntry=="IT" & year==2012 /*CHES10*/
replace lreconL=.    if cntry=="IT" & year==2014 /*CHES14*/
replace lreconL=.    if cntry=="IT" & year==2016 /*CHES14*/
replace lreconL=.    if cntry=="IT" & year==2018 /*CHES14*/
replace lreconL=.    if cntry=="IT" & year==2020 /*CHES19*/

replace lreconL=4.5  if cntry=="LU" & year==2014 /*CHES14*/
replace lreconL=4.5  if cntry=="LU" & year==2016 /*CHES14*/
replace lreconL=4.5  if cntry=="LU" & year==2018 /*CHES14*/
replace lreconL=4    if cntry=="LU" & year==2020 /*CHES19*/

replace lreconL=1.5  if cntry=="NO" & year==2014 /*CHES14*/
replace lreconL=1.5  if cntry=="NO" & year==2016 /*CHES14*/
replace lreconL=1.5  if cntry=="NO" & year==2018 /*CHES14*/
replace lreconL=1.5  if cntry=="NO" & year==2020 /*CHES19*/

replace lreconL=2    if cntry=="CH" & year==2014 /*CHES14*/
replace lreconL=2    if cntry=="CH" & year==2016 /*CHES14*/
replace lreconL=2    if cntry=="CH" & year==2018 /*CHES14*/
replace lreconL=1.63 if cntry=="CH" & year==2020 /*CHES19*/

replace lreconL=3.78  if cntry=="NL" & year==2002 /*CHES02*/
replace lreconL=3.78  if cntry=="NL" & year==2004 /*CHES02*/
replace lreconL=3.56  if cntry=="NL" & year==2006 /*CHES06*/
replace lreconL=3.56  if cntry=="NL" & year==2008 /*CHES06*/
replace lreconL=3.57  if cntry=="NL" & year==2010 /*CHES10*/
replace lreconL=3.57  if cntry=="NL" & year==2012 /*CHES10*/
replace lreconL=3.22  if cntry=="NL" & year==2014 /*CHES14*/
replace lreconL=3.22  if cntry=="NL" & year==2016 /*CHES14*/
replace lreconL=3.22  if cntry=="NL" & year==2018 /*CHES14*/
replace lreconL=3.61  if cntry=="NL" & year==2020 /*CHES19*/

replace lreconL=3.71  if cntry=="SE" & year==2002 /*CHES02*/
replace lreconL=3.71  if cntry=="SE" & year==2004 /*CHES02*/
replace lreconL=3.22  if cntry=="SE" & year==2006 /*CHES06*/
replace lreconL=3.22  if cntry=="SE" & year==2008 /*CHES06*/
replace lreconL=3.43  if cntry=="SE" & year==2010 /*CHES10*/
replace lreconL=3.43  if cntry=="SE" & year==2012 /*CHES10*/
replace lreconL=3.43  if cntry=="SE" & year==2014 /*CHES14*/
replace lreconL=3.43  if cntry=="SE" & year==2016 /*CHES14*/
replace lreconL=3.43  if cntry=="SE" & year==2018 /*CHES14*/
replace lreconL=4.11  if cntry=="SE" & year==2020 /*CHES19*/

replace lreconL=3.86  if cntry=="PT" & year==2002 /*CHES02*/
replace lreconL=3.86  if cntry=="PT" & year==2004 /*CHES02*/
replace lreconL=4.8   if cntry=="PT" & year==2006 /*CHES06*/
replace lreconL=4.8   if cntry=="PT" & year==2008 /*CHES06*/
replace lreconL=4     if cntry=="PT" & year==2010 /*CHES10*/
replace lreconL=4     if cntry=="PT" & year==2012 /*CHES10*/
replace lreconL=4.67  if cntry=="PT" & year==2014 /*CHES14*/
replace lreconL=4.67  if cntry=="PT" & year==2016 /*CHES14*/
replace lreconL=4.67  if cntry=="PT" & year==2018 /*CHES14*/
replace lreconL=4     if cntry=="PT" & year==2020 /*CHES19*/

* =====================================
* =    L-R LOCATION OF MAIN RR PARTY 
*  =    IN EVERY CNTRYEAR (CHES DATA)*
* =====================================
/*
LIST OF MAIN RR PARTIES PER COUNTRY:
AT-FPO
BE-National Front, Vlaams Bloc
DK-Danish People's Party (DPP)
FI-True Finns
FR-Front National
GR-LAOS
IT-Lega Nord, National Alliance
NL-Pim Fortuyn List (02-08) , Freedom Party (10-12)
NO-Progress Party
IS - Liberal Party(04); Liberal Party Citizens' Movement(12) 
SE-Sweden Democrats (10-12)
GB- UKIP */

gen lreconR=.

replace lreconR=7.31 if cntry=="AT" & year==2002 /*CHES02*/
replace lreconR=7.31 if cntry=="AT" & year==2004 /*CHES02*/
replace lreconR=4.83 if cntry=="AT" & year==2006 /*CHES06*/
replace lreconR=4.83 if cntry=="AT" & year==2008 /*CHES06*/
replace lreconR=5    if cntry=="AT" & year==2010 /*CHES10*/
replace lreconR=5    if cntry=="AT" & year==2012 /*CHES10*/
replace lreconR=5.5  if cntry=="AT" & year==2014 /*CHES14*/
replace lreconR=5.5  if cntry=="AT" & year==2016 /*CHES14*/
replace lreconR=5.5  if cntry=="AT" & year==2018 /*CHES14*/
replace lreconR=6.5  if cntry=="AT" & year==2020 /*CHES19*/

replace lreconR=7.9  if cntry=="BE" & year==2002 /*CHES02*/
replace lreconR=7.9  if cntry=="BE" & year==2004 /*CHES02*/
replace lreconR=7.13 if cntry=="BE" & year==2006 /*CHES06*/
replace lreconR=7.13 if cntry=="BE" & year==2008 /*CHES06*/
replace lreconR=7.93 if cntry=="BE" & year==2010 /*CHES10*/
replace lreconR=7.93 if cntry=="BE" & year==2012 /*CHES10*/
replace lreconR=5.5  if cntry=="BE" & year==2014 /*CHES14*/
replace lreconR=5.5  if cntry=="BE" & year==2016 /*CHES14*/
replace lreconR=5.5  if cntry=="BE" & year==2018 /*CHES14*/
replace lreconR=5    if cntry=="BE" & year==2020 /*CHES19*/

replace lreconR=6.08 if cntry=="DK" & year==2002 /*CHES02*/
replace lreconR=6.08 if cntry=="DK" & year==2004 /*CHES02*/
replace lreconR=4.75 if cntry=="DK" & year==2006 /*CHES06*/
replace lreconR=4.75 if cntry=="DK" & year==2008 /*CHES06*/
replace lreconR=5.45 if cntry=="DK" & year==2010 /*CHES10*/
replace lreconR=5.45 if cntry=="DK" & year==2012 /*CHES10*/
replace lreconR=4.5  if cntry=="DK" & year==2014 /*CHES14*/
replace lreconR=4.5  if cntry=="DK" & year==2016 /*CHES14*/
replace lreconR=4.5  if cntry=="DK" & year==2018 /*CHES14*/
replace lreconR=4.43 if cntry=="DK" & year==2020 /*CHES19*/

replace lreconR=.    if cntry=="FI" & year==2002 /*CHES99*/
replace lreconR=.    if cntry=="FI" & year==2004 /*CHES99*/
replace lreconR=4.82 if cntry=="FI" & year==2006 /*CHES06*/
replace lreconR=4.82 if cntry=="FI" & year==2008 /*CHES06*/
replace lreconR=4.3  if cntry=="FI" & year==2010 /*CHES10*/
replace lreconR=4.3  if cntry=="FI" & year==2012 /*CHES10*/
replace lreconR=4.11 if cntry=="FI" & year==2014 /*CHES14*/
replace lreconR=4.11 if cntry=="FI" & year==2016 /*CHES14*/
replace lreconR=4.11 if cntry=="FI" & year==2018 /*CHES14*/
replace lreconR=6.43 if cntry=="FI" & year==2020 /*CHES19*/

replace lreconR=6    if cntry=="FR" & year==2002 /*CHES02*/
replace lreconR=6    if cntry=="FR" & year==2004 /*CHES02*/
replace lreconR=6.63 if cntry=="FR" & year==2006 /*CHES06*/
replace lreconR=6.63 if cntry=="FR" & year==2008 /*CHES10*/
replace lreconR=6.5  if cntry=="FR" & year==2010 /*CHES10*/
replace lreconR=6.5  if cntry=="FR" & year==2012 /*CHES10*/
replace lreconR=5.9  if cntry=="FR" & year==2014 /*CHES14*/
replace lreconR=5.9  if cntry=="FR" & year==2016 /*CHES14*/
replace lreconR=5.9  if cntry=="FR" & year==2018 /*CHES14*/
replace lreconR=6.87 if cntry=="FR" & year==2020 /*RN,CHES19*/

replace lreconR=.    if cntry=="GR" & year==2002 /*CHES02, laos party*/
replace lreconR=.    if cntry=="GR" & year==2004 /*CHES02*/
replace lreconR=5.33 if cntry=="GR" & year==2006 /*CHES06*/
replace lreconR=5.33 if cntry=="GR" & year==2008 /*CHES10*/
replace lreconR=5.9  if cntry=="GR" & year==2010 /*CHES10*/
replace lreconR=5.9  if cntry=="GR" & year==2012 /*CHES10*/
replace lreconR=5.33 if cntry=="GR" & year==2014 /*CHES14*/
replace lreconR=5.33 if cntry=="GR" & year==2016 /*CHES14*/
replace lreconR=5.33 if cntry=="GR" & year==2018 /*CHES14*/
replace lreconR=4.37 if cntry=="GR" & year==2020 /*CHES19, el party*/

replace lreconR=7.28 if cntry=="IT" & year==2002 /*CHES02, LN*/
replace lreconR=7.28 if cntry=="IT" & year==2004 /*CHES02*/
replace lreconR=8.14 if cntry=="IT" & year==2006 /*CHES06*/
replace lreconR=8.14 if cntry=="IT" & year==2008 /*CHES*/
replace lreconR=7.33 if cntry=="IT" & year==2010 /*CHES10*/
replace lreconR=7.33 if cntry=="IT" & year==2012 /*CHES10*/
replace lreconR=7.28 if cntry=="IT" & year==2014 /*CHES14*/
replace lreconR=7.28 if cntry=="IT" & year==2016 /*CHES14*/
replace lreconR=7.28 if cntry=="IT" & year==2018 /*CHES14*/
replace lreconR=7.68 if cntry=="IT" & year==2020 /*CHES19*/

replace lreconR=8.11 if cntry=="NL" & year==2002 /*CHES02, LPF*/
replace lreconR=8.11 if cntry=="NL" & year==2004 /*CHES02, LPF*/
replace lreconR=8.29 if cntry=="NL" & year==2006 /*CHES06, PVV*/
replace lreconR=8.29 if cntry=="NL" & year==2008 /*CHES10, PVV*/
replace lreconR=5.23 if cntry=="NL" & year==2010 /*CHES10, PVV*/
replace lreconR=4.55 if cntry=="NL" & year==2014 /*CHES14, PVV*/
replace lreconR=4.55 if cntry=="NL" & year==2016 /*CHES14, PVV*/
replace lreconR=4.55 if cntry=="NL" & year==2018 /*CHES14, PVV*/
replace lreconR=6.46 if cntry=="NL" & year==2020 /*CHES19, PVV*/

replace lreconR=.    if cntry=="SE" & year==2002 /*CHES02*/
replace lreconR=.    if cntry=="SE" & year==2004 /*CHES02*/
replace lreconR=.    if cntry=="SE" & year==2006 /*CHES06*/
replace lreconR=.    if cntry=="SE" & year==2008 /*CHES10*/
replace lreconR=5.54 if cntry=="SE" & year==2010 /*CHES10*/
replace lreconR=5.54 if cntry=="SE" & year==2012 /*CHES10*/
replace lreconR=5.4  if cntry=="SE" & year==2014 /*CHES14*/
replace lreconR=5.4  if cntry=="SE" & year==2016 /*CHES14*/
replace lreconR=5.4  if cntry=="SE" & year==2018 /*CHES14*/
replace lreconR=5.59 if cntry=="SE" & year==2020 /*CHES19*/


replace lreconR=7.5 if cntry=="NO" & year==2014 /*FrP, CHES14, taken seperatly from the 2014 wave */
replace lreconR=7.5 if cntry=="NO" & year==2016 /*FrP,CHES14, taken seperatly from the 2014 wave */
replace lreconR=7.5 if cntry=="NO" & year==2018 /*FrP,CHES14, taken seperatly from the 2014 wave */
replace lreconR=7.9 if cntry=="NO" & year==2020 /*FrP,CHES19, taken seperatly from the 2014 wave */
replace lreconR=7.5 if cntry=="CH" & year==2014 /*SVP,CHES14, taken seperatly from the 2014 wave */
replace lreconR=7.5 if cntry=="CH" & year==2016 /*SVP,CHES14, taken seperatly from the 2014 wave */
replace lreconR=7.5 if cntry=="CH" & year==2018 /*SVP,CHES14, taken seperatly from the 2014 wave */
replace lreconR=8.18 if cntry=="CH" & year==2020 /*SVP,CHES14, taken seperatly from the 2014 wave */

replace lreconR=8.57 if cntry=="GB"& year==2016 /*CHES14*/

gen galtanL=. /*galtan values are applied for main left-wing parties*/
replace galtanL=3.38 if cntry=="AT" & year==2002 /*CHES02*/
replace galtanL=3.38 if cntry=="AT" & year==2004 /*CHES02*/
replace galtanL=3.5  if cntry=="AT" & year==2006 /*CHES06*/
replace galtanL=3.5  if cntry=="AT" & year==2008 /*CHES06*/
replace galtanL=3.93 if cntry=="AT" & year==2010 /*CHES10*/
replace galtanL=3.93 if cntry=="AT" & year==2012 /*CHES10*/
replace galtanL=4    if cntry=="AT" & year==2014 /*CHES14*/
replace galtanL=4    if cntry=="AT" & year==2016 /*CHES14*/
replace galtanL=4    if cntry=="AT" & year==2018 /*CHES14*/
replace galtanL=3.8  if cntry=="AT" & year==2020 /*CHES19*/

replace galtanL=4    if cntry=="BE" & year==2002 /*CHES02*/
replace galtanL=4    if cntry=="BE" & year==2004 /*CHES02*/
replace galtanL=2.83 if cntry=="BE" & year==2006 /*CHES06*/
replace galtanL=2.83 if cntry=="BE" & year==2008 /*CHES06*/
replace galtanL=2.86 if cntry=="BE" & year==2010 /*CHES10*/
replace galtanL=2.86 if cntry=="BE" & year==2012 /*CHES10*/
replace galtanL=3.4  if cntry=="BE" & year==2014 /*CHES14*/
replace galtanL=3.4  if cntry=="BE" & year==2016 /*CHES14*/
replace galtanL=3.4  if cntry=="BE" & year==2018 /*CHES14*/
replace galtanL=2.91 if cntry=="BE" & year==2020 /*CHES19*/

replace galtanL=4.57 if cntry=="DE" & year==2002 /*CHES02*/
replace galtanL=4.57 if cntry=="DE" & year==2004 /*CHES02*/
replace galtanL=4.45 if cntry=="DE" & year==2006 /*CHES06*/
replace galtanL=4.45 if cntry=="DE" & year==2008 /*CHES06*/
replace galtanL=4.5  if cntry=="DE" & year==2010 /*CHES10*/ 
replace galtanL=4.5  if cntry=="DE" & year==2012 /*CHES10*/
replace galtanL=4.15 if cntry=="DE" & year==2014 /*CHES14*/ 
replace galtanL=4.15 if cntry=="DE" & year==2016 /*CHES14*/
replace galtanL=4.15 if cntry=="DE" & year==2018 /*CHES14*/ 
replace galtanL=3.38 if cntry=="DE" & year==2020 /*CHES19*/

replace galtanL=4.38 if cntry=="DK" & year==2002 /*CHES02*/
replace galtanL=4.38 if cntry=="DK" & year==2004 /*CHES02*/
replace galtanL=4.13 if cntry=="DK" & year==2006 /*CHES06*/
replace galtanL=4.13 if cntry=="DK" & year==2008 /*CHES06*/
replace galtanL=5    if cntry=="DK" & year==2010 /*CHES10*/
replace galtanL=5    if cntry=="DK" & year==2012 /*CHES10*/
replace galtanL=5.2  if cntry=="DK" & year==2014 /*CHES14*/
replace galtanL=5.2  if cntry=="DK" & year==2016 /*CHES14*/
replace galtanL=5.2  if cntry=="DK" & year==2018 /*CHES14*/
replace galtanL=5    if cntry=="DK" & year==2020 /*CHES19*/

replace galtanL= 3.69 if cntry=="ES" & year==2002 /*CHES02*/
replace galtanL= 3.69 if cntry=="ES" & year==2004 /*CHES02*/
replace galtanL=2.15  if cntry=="ES" & year==2006 /*CHES06*/
replace galtanL=2.15  if cntry=="ES" & year==2008 /*CHES06*/
replace galtanL=2.33  if cntry=="ES" & year==2010 /*CHES10*/
replace galtanL=2.33  if cntry=="ES" & year==2012 /*CHES10*/
replace galtanL=2.2   if cntry=="ES" & year==2014 /*CHES14*/
replace galtanL=2.2   if cntry=="ES" & year==2016 /*CHES14*/
replace galtanL=2.2   if cntry=="ES" & year==2018 /*CHES14*/
replace galtanL=2.93  if cntry=="ES" & year==2020 /*CHES19*/

replace galtanL=3.17 if cntry=="FR" & year==2002 /*CHES02*/
replace galtanL=3.17 if cntry=="FR" & year==2004 /*CHES02*/
replace galtanL=2.75 if cntry=="FR" & year==2006 /*CHES06*/
replace galtanL=2.75 if cntry=="FR" & year==2008 /*CHES06*/
replace galtanL=2.33 if cntry=="FR" & year==2010 /*CHES10*/
replace galtanL=2.33 if cntry=="FR" & year==2012 /*CHES10*/
replace galtanL=3.36 if cntry=="FR" & year==2014 /*CHES14*/
replace galtanL=3.36 if cntry=="FR" & year==2016 /*CHES14*/
replace galtanL=3.36 if cntry=="FR" & year==2018 /*CHES14*/
replace galtanL=2.75 if cntry=="FR" & year==2020 /*CHES19*/

replace galtanL=4.83 if cntry=="GB" & year==2002 /*CHES02*/
replace galtanL=4.83 if cntry=="GB" & year==2004 /*CHES02*/
replace galtanL=4.67 if cntry=="GB" & year==2006 /*CHES06*/
replace galtanL=4.67 if cntry=="GB" & year==2008 /*CHES06*/
replace galtanL=4.06 if cntry=="GB" & year==2010 /*CHES10*/
replace galtanL=4.06 if cntry=="GB" & year==2012 /*CHES10*/
replace galtanL=3.43 if cntry=="GB" & year==2014 /*CHES14*/
replace galtanL=3.43 if cntry=="GB" & year==2016 /*CHES14*/
replace galtanL=3.43 if cntry=="GB" & year==2018 /*CHES14*/
replace galtanL=2.29 if cntry=="GB" & year==2020 /*CHES19*/

replace galtanL=3.86 if cntry=="GR" & year==2002 /*CHES02*/
replace galtanL=3.86 if cntry=="GR" & year==2004 /*CHES02*/
replace galtanL=3.25 if cntry=="GR" & year==2006 /*CHES06*/
replace galtanL=3.25 if cntry=="GR" & year==2008 /*CHES06*/
replace galtanL=2.82 if cntry=="GR" & year==2010 /*CHES10*/
replace galtanL=2.82 if cntry=="GR" & year==2012 /*CHES10*/
replace galtanL=4    if cntry=="GR" & year==2014 /*CHES14*/
replace galtanL=4    if cntry=="GR" & year==2016 /*CHES14*/
replace galtanL=4    if cntry=="GR" & year==2018 /*CHES14*/
replace galtanL=3.88 if cntry=="GR" & year==2020 /*CHES19*/

replace galtanL=3.75  if cntry=="IE" & year==2002 /*CHES02*/
replace galtanL=3.75  if cntry=="IE" & year==2004 /*CHES02*/
replace galtanL=2.89  if cntry=="IE" & year==2006 /*CHES06*/
replace galtanL=2.89  if cntry=="IE" & year==2008 /*CHES06*/
replace galtanL=3.75  if cntry=="IE" & year==2010 /*CHES10*/
replace galtanL=3.75  if cntry=="IE" & year==2012 /*CHES10*/
replace galtanL=3.75  if cntry=="IE" & year==2014 /*CHES14*/
replace galtanL=3.75  if cntry=="IE" & year==2016 /*CHES14*/
replace galtanL=3.75  if cntry=="IE" & year==2018 /*CHES14*/
replace galtanL=2.86  if cntry=="IE" & year==2020 /*CHES19*/

replace galtanL=2.54 if cntry=="IT" & year==2002 /*CHES02*/
replace galtanL=2.54 if cntry=="IT" & year==2004 /*CHES02*/
replace galtanL=2.88 if cntry=="IT" & year==2006 /*CHES06*/
replace galtanL=2.88 if cntry=="IT" & year==2008 /*CHES06*/
replace galtanL=.    if cntry=="IT" & year==2010 /*CHES10*/
replace galtanL=.    if cntry=="IT" & year==2012 /*CHES10*/
replace galtanL=.    if cntry=="IT" & year==2014 /*CHES14*/
replace galtanL=.    if cntry=="IT" & year==2016 /*CHES14*/
replace galtanL=.    if cntry=="IT" & year==2018 /*CHES14*/
replace galtanL=.    if cntry=="IT" & year==2020 /*CHES19*/

replace galtanL=1  if cntry=="LU" & year==2014 /*CHES14*/
replace galtanL=1  if cntry=="LU" & year==2016 /*CHES14*/
replace galtanL=1  if cntry=="LU" & year==2018 /*CHES14*/
replace galtanL=4  if cntry=="LU" & year==2020 /*CHES19*/

replace galtanL=2   if cntry=="NO" & year==2014 /*CHES14*/
replace galtanL=2   if cntry=="NO" & year==2016 /*CHES14*/
replace galtanL=2   if cntry=="NO" & year==2018 /*CHES14*/
replace galtanL=3.2 if cntry=="NO" & year==2020 /*CHES19*/

replace galtanL=2    if cntry=="CH" & year==2014 /*CHES14*/
replace galtanL=2    if cntry=="CH" & year==2016 /*CHES14*/
replace galtanL=2    if cntry=="CH" & year==2018 /*CHES14*/
replace galtanL=1.36 if cntry=="CH" & year==2020 /*CHES19*/

replace galtanL=3.25  if cntry=="NL" & year==2002 /*CHES02*/
replace galtanL=3.25  if cntry=="NL" & year==2004 /*CHES02*/
replace galtanL=3.7   if cntry=="NL" & year==2006 /*CHES06*/
replace galtanL=3.7   if cntry=="NL" & year==2008 /*CHES06*/
replace galtanL=4     if cntry=="NL" & year==2010 /*CHES10*/
replace galtanL=4     if cntry=="NL" & year==2012 /*CHES10*/
replace galtanL=3     if cntry=="NL" & year==2014 /*CHES14*/
replace galtanL=3     if cntry=="NL" & year==2016 /*CHES14*/
replace galtanL=3     if cntry=="NL" & year==2018 /*CHES14*/
replace galtanL=3.07  if cntry=="NL" & year==2020 /*CHES19*/

replace galtanL=4.83 if cntry=="SE" & year==2002 /*CHES02*/
replace galtanL=4.83 if cntry=="SE" & year==2004 /*CHES02*/
replace galtanL=4.22 if cntry=="SE" & year==2006 /*CHES06*/
replace galtanL=4.22 if cntry=="SE" & year==2008 /*CHES06*/
replace galtanL=4.21 if cntry=="SE" & year==2010 /*CHES10*/
replace galtanL=4.21 if cntry=="SE" & year==2012 /*CHES10*/
replace galtanL=3.62 if cntry=="SE" & year==2014 /*CHES14*/
replace galtanL=3.62 if cntry=="SE" & year==2016 /*CHES14*/
replace galtanL=3.62 if cntry=="SE" & year==2018 /*CHES14*/
replace galtanL=4.41 if cntry=="SE" & year==2020 /*CHES19*/

replace galtanL=3.43  if cntry=="PT" & year==2002 /*CHES02*/
replace galtanL=3.43  if cntry=="PT" & year==2004 /*CHES02*/
replace galtanL=3.8   if cntry=="PT" & year==2006 /*CHES06*/
replace galtanL=3.8   if cntry=="PT" & year==2008 /*CHES06*/
replace galtanL=2.33  if cntry=="PT" & year==2010 /*CHES10*/
replace galtanL=2.33  if cntry=="PT" & year==2012 /*CHES10*/
replace galtanL=3.16  if cntry=="PT" & year==2014 /*CHES14*/
replace galtanL=3.16  if cntry=="PT" & year==2016 /*CHES14*/
replace galtanL=3.16  if cntry=="PT" & year==2018 /*CHES14*/
replace galtanL=4.37  if cntry=="PT" & year==2020 /*CHES19*/

replace galtanL=3.89 if cntry=="FI" & year==2002 /*CHES02*/
replace galtanL=3.89 if cntry=="FI" & year==2004 /*CHES02*/
replace galtanL=5    if cntry=="FI" & year==2006 /*CHES06*/
replace galtanL=5    if cntry=="FI" & year==2008 /*CHES06*/
replace galtanL=4.7  if cntry=="FI" & year==2010 /*CHES10*/
replace galtanL=4.7  if cntry=="FI" & year==2012 /*CHES10*/
replace galtanL=3.22 if cntry=="FI" & year==2014 /*CHES14*/
replace galtanL=3.22 if cntry=="FI" & year==2016 /*CHES14*/
replace galtanL=3.22 if cntry=="FI" & year==2018 /*CHES14*/
replace galtanL=3.28 if cntry=="FI" & year==2020 /*CHES19*/

gen galtanR=.

replace galtanR=9    if cntry=="AT" & year==2002 /*CHES02*/
replace galtanR=9    if cntry=="AT" & year==2004 /*CHES02*/
replace galtanR=9.67 if cntry=="AT" & year==2006 /*CHES06*/
replace galtanR=9.67 if cntry=="AT" & year==2008 /*CHES06*/
replace galtanR=8.71 if cntry=="AT" & year==2010 /*CHES10*/
replace galtanR=8.71 if cntry=="AT" & year==2012 /*CHES10*/
replace galtanR=8.8  if cntry=="AT" & year==2014 /*CHES14*/
replace galtanR=8.8  if cntry=="AT" & year==2016 /*CHES14*/
replace galtanR=8.8  if cntry=="AT" & year==2018 /*CHES14*/
replace galtanR=8.9  if cntry=="AT" & year==2020 /*CHES19*/

replace galtanR=9.37 if cntry=="BE" & year==2002 /*CHES02*/
replace galtanR=9.37 if cntry=="BE" & year==2004 /*CHES02*/
replace galtanR=9.5  if cntry=="BE" & year==2006 /*CHES06*/
replace galtanR=9.5  if cntry=="BE" & year==2008 /*CHES06*/
replace galtanR=9.6  if cntry=="BE" & year==2010 /*CHES10*/
replace galtanR=9.6  if cntry=="BE" & year==2012 /*CHES10*/
replace galtanR=9    if cntry=="BE" & year==2014 /*CHES14*/
replace galtanR=9    if cntry=="BE" & year==2016 /*CHES14*/
replace galtanR=9    if cntry=="BE" & year==2018 /*CHES14*/
replace galtanR=8    if cntry=="BE" & year==2020 /*CHES19*/

replace galtanR=8.92 if cntry=="DK" & year==2002 /*CHES02*/
replace galtanR=8.92 if cntry=="DK" & year==2004 /*CHES02*/
replace galtanR=7.63 if cntry=="DK" & year==2006 /*CHES06*/
replace galtanR=7.63 if cntry=="DK" & year==2008 /*CHES06*/
replace galtanR=9.4  if cntry=="DK" & year==2010 /*CHES10*/
replace galtanR=9.4  if cntry=="DK" & year==2012 /*CHES10*/
replace galtanR=8.4  if cntry=="DK" & year==2014 /*CHES14*/
replace galtanR=8.4  if cntry=="DK" & year==2016 /*CHES14*/
replace galtanR=8.4  if cntry=="DK" & year==2018 /*CHES14*/
replace galtanR=8    if cntry=="DK" & year==2020 /*CHES19*/

replace galtanR=.    if cntry=="FI" & year==2002 /*CHES99*/
replace galtanR=.    if cntry=="FI" & year==2004 /*CHES99*/
replace galtanR=7.64 if cntry=="FI" & year==2006 /*CHES06*/
replace galtanR=7.64 if cntry=="FI" & year==2008 /*CHES06*/
replace galtanR=7.5  if cntry=="FI" & year==2010 /*CHES10*/
replace galtanR=7.5  if cntry=="FI" & year==2012 /*CHES10*/
replace galtanR=9.11 if cntry=="FI" & year==2014 /*CHES14*/
replace galtanR=9.11 if cntry=="FI" & year==2016 /*CHES14*/
replace galtanR=9.11 if cntry=="FI" & year==2018 /*CHES14*/
replace galtanR=8.78 if cntry=="FI" & year==2020 /*CHES19*/

replace galtanR=9.8  if cntry=="FR" & year==2002 /*CHES02*/
replace galtanR=9.8  if cntry=="FR" & year==2004 /*CHES02*/
replace galtanR=9.25 if cntry=="FR" & year==2006 /*CHES06*/
replace galtanR=9.25 if cntry=="FR" & year==2008 /*CHES10*/
replace galtanR=9.55 if cntry=="FR" & year==2010 /*CHES10*/
replace galtanR=9.55 if cntry=="FR" & year==2012 /*CHES10*/
replace galtanR=8.92 if cntry=="FR" & year==2014 /*CHES14*/
replace galtanR=8.92 if cntry=="FR" & year==2016 /*CHES14*/
replace galtanR=8.92 if cntry=="FR" & year==2018 /*CHES14*/
replace galtanR=8.12 if cntry=="FR" & year==2020 /*RN, CHES19*/

replace galtanR=.    if cntry=="GR" & year==2002 /*CHES02*/
replace galtanR=.    if cntry=="GR" & year==2004 /*CHES02*/
replace galtanR=9.63 if cntry=="GR" & year==2006 /*CHES06*/
replace galtanR=9.63 if cntry=="GR" & year==2008 /*CHES10*/
replace galtanR=9.55 if cntry=="GR" & year==2010 /*CHES10*/
replace galtanR=9.55 if cntry=="GR" & year==2012 /*CHES10*/
replace galtanR=8.33 if cntry=="GR" & year==2014 /*CHES14*/
replace galtanR=8.33 if cntry=="GR" & year==2016 /*CHES14*/
replace galtanR=8.33 if cntry=="GR" & year==2018 /*CHES14*/
replace galtanR=9.37 if cntry=="GR" & year==2020 /*CHES19*/

replace galtanR=8.23 if cntry=="IT" & year==2002 /*CHES02*/
replace galtanR=8.23 if cntry=="IT" & year==2004 /*CHES02*/
replace galtanR=8.75 if cntry=="IT" & year==2006 /*CHES06*/
replace galtanR=8.75 if cntry=="IT" & year==2008 /*CHES*/
replace galtanR=8.44 if cntry=="IT" & year==2010 /*CHES10*/
replace galtanR=8.44 if cntry=="IT" & year==2012 /*CHES10*/
replace galtanR=9.14 if cntry=="IT" & year==2014 /*CHES14*/
replace galtanR=9.14 if cntry=="IT" & year==2016 /*CHES14*/
replace galtanR=9.14 if cntry=="IT" & year==2018 /*CHES14*/
replace galtanR=9.21 if cntry=="IT" & year==2020 /*CHES19*/

replace galtanR=5.44 if cntry=="NL" & year==2002 /*CHES02, LPF*/
replace galtanR=5.44 if cntry=="NL" & year==2004 /*CHES02, LPF*/
replace galtanR=6.57 if cntry=="NL" & year==2006 /*CHES06, PVV*/
replace galtanR=6.57 if cntry=="NL" & year==2008 /*CHES10, PVV*/
replace galtanR=7.15 if cntry=="NL" & year==2010 /*CHES10, PVV*/
replace galtanR=7.78 if cntry=="NL" & year==2014 /*CHES14, PVV*/
replace galtanR=7.78 if cntry=="NL" & year==2016 /*CHES14, PVV*/
replace galtanR=7.78 if cntry=="NL" & year==2018 /*CHES14, PVV*/
replace galtanR=7.23 if cntry=="NL" & year==2020 /*CHES19, PVV*/

replace galtanR=.    if cntry=="SE" & year==2002 /*CHES02*/
replace galtanR=.    if cntry=="SE" & year==2004 /*CHES02*/
replace galtanR=.    if cntry=="SE" & year==2006 /*CHES06*/
replace galtanR=.    if cntry=="SE" & year==2008 /*CHES10*/
replace galtanR=8.25 if cntry=="SE" & year==2010 /*CHES10*/
replace galtanR=8.25 if cntry=="SE" & year==2012 /*CHES10*/
replace galtanR=9.24  if cntry=="SE" & year==2014 /*CHES14*/
replace galtanR=9.24  if cntry=="SE" & year==2016 /*CHES14*/
replace galtanR=9.24  if cntry=="SE" & year==2018 /*CHES14*/
replace galtanR=8.76  if cntry=="SE" & year==2020 /*CHES19*/

replace galtanR=7.5 if cntry=="NO" & year==2014 /*CHES14, taken seperatly from the 2014 wave */
replace galtanR=7.5 if cntry=="NO" & year==2016 /*CHES14, taken seperatly from the 2014 wave */
replace galtanR=7.5 if cntry=="NO" & year==2018 /*CHES14, taken seperatly from the 2014 wave */
replace galtanR=6.8 if cntry=="NO" & year==2020 /*CHES14, taken seperatly from the 2019 wave */

replace galtanR=9.37 if cntry=="CH" & year==2014 /*CHES14, taken seperatly from the 2014 wave */
replace galtanR=9.37 if cntry=="CH" & year==2016 /*CHES14, taken seperatly from the 2014 wave */
replace galtanR=9.37 if cntry=="CH" & year==2018 /*CHES14, taken seperatly from the 2014 wave */
replace galtanR=9.36 if cntry=="CH" & year==2020 /*CHES19, taken seperatly from the 2014 wave */

replace galtanR=9.29 if cntry=="GB"& year==2016 /*CHES14*/

/*ECONOMIC DISTANCE BETWEEN RADICAL RIGHT AND LEFT*/
gen econdistance=lreconR-lreconL
* =================================
/*(2) OCCUPATIONAL SEX SEGREGATION*/     
* =================================

/*we generate a variable that taps gender seggregation in manual sectors (7-9)*/

/*number of male & female workers in occupation 7, by cntryear*/  
by cntry year , sort: egen frqmocp7=count(male) 	if male==1 & occupation==7 
by cntry year , sort: egen frqfocp7=count(male) 	if male==0 & occupation==7 

/*number of male & female workers in occupation 8, by cntryear*/  
by cntry year , sort: egen frqmocp8=count(male) 	if male==1 & occupation==8 
by cntry year , sort: egen frqfocp8=count(male) 	if male==0 & occupation==8 

/*number of male & female workers in occupation 9, by cntryear*/  
by cntry year , sort: egen frqmocp9=count(male) 	if male==1 & occupation==9 
by cntry year , sort: egen frqfocp9=count(male) 	if male==0 & occupation==9 

/* For each respondent generate two variables that capture number of F & M in occupation on the same 
   row to allow for arithmetic.*/
by cntry year , sort: egen ocp9m= max(frqmocp9)
by cntry year , sort: egen ocp9f= max(frqfocp9)
by cntry year , sort: egen ocp8m= max(frqmocp8)
by cntry year , sort: egen ocp8f= max(frqfocp8)
by cntry year , sort: egen ocp7m= max(frqmocp7)
by cntry year , sort: egen ocp7f= max(frqfocp7)

by cntry year, sort: gen manseg=((ocp7m+ocp8m+ocp9m)-(ocp7f+ocp8f+ocp9f))/ ///
((ocp7m+ocp8m+ocp9m)+(ocp7f+ocp8f+ocp9f))

gen manul_dum=.
replace manul_dum=1 if (occupation==7 | occupation==8|  occupation==9)
replace manul_dum=0 if (occupation<6& occupation>0)

by male, sort: tab manul_dum  /*34% of men and 16% of women are manual workers, this information is reported in the paper*/ 
by manul_dum, sort: ta male /*31% of manual workers are F; 68% are M, reported in the paper*/

by occupation, sort: tab male if (rress1==1 | rress2==1 | ///
rress3==1 | rress4==1 | rress5==1 | rress6==1 | rress7==1 | ///
 rress8==1| rress9==1 | rress10==1) & (occupation!=0 & occupation!=6) , nol

/*unemployment*/
by cntry year , sort: egen n=count(male) 
by cntry year , sort: egen nuneployed=count(male) if unemp==1
gen unemployed=nuneployed/n
bys country year: ta unemployed

/*Unionized*/
by cntry year , sort: egen nunionized=count(male) if um==1
gen unionized=nunionized/n
bys country year: ta unionized

/*COLLAPSE DATA INTO GENDER GAP & DIVERSITY*/
collapse (max) manseg  gendergappfl ggsdper lreconL lreconR galtanL galtanR ///
cntryrr ggrrunique1 econdistance unionized unemployed  ///
 , by (cntry year) 
 /*(4) REGRESSION ANALYSIS*/

* GENERATE NUMERICAL VARIABLE FOR COUNTRY 
egen country = group(cntry)              
label define country 1 "AT" 2 "BE" 3 "CH" 4 "DE" ///
5 "DK" 6 "ES" 7 "FI" 8 "FR" 9 "GB" 10 "GR" 11 "IE" ///
12 "IS" 13 "IT" 14 "LU" 15 "NL" 16 "NO" 17 "PT" 18 "SE" , replace
label values country country
xtset country year
gen year_2dig = string(mod(year,100), "%02.0f")  
gen cntryear=cntry+year_2dig
ta cntryear /*151 cntryear observations, reported in the paper*/
*********************************************
set scheme plotplain 

/*L-R ECON FIGURE*/ 
sort lreconL
ta lreconL
edit cntryear lreconL /*reported in the text*/
sort lreconR
edit cntryear lreconR /*reported in the text*/

/*MANUAL LABOR MARKET SEGREGATION*/
sort manseg
edit cntryear manseg /*lowest and highest values are reported in the paper*/

*1. gender gap on the left = f(seg, lreconL, interaction)

*Table 2, Model 1: where RR is present
reg gendergappfl c.manseg##c.lreconL  i.year  i.country if cntryrr==1, 
outreg2 using TableH.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 
*interflex gendergappfl  manseg  lreconL if cntryrr==1. , type(linear) fe(country year)  dlabel("male dom. manual sectors") xlabel("ec. position of SDPs") title("H2") 
*graph save "h2_w/o controls", replace

* Table 2, Model 2: controling for galtan and lreconR
reg gendergappfl   c.manseg##c.lreconL  galtanL lreconR galtanR     i.country i.year if cntryrr==1 
outreg2 using TableH.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

*Table 2, Model 3: where RR is not present
reg gendergappfl  c.manseg##c.lreconL  galtanL i.year  i.country if cntryrr==0
outreg2 using TableH.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

*interflex gendergappfl  manseg  lreconL galtanL lreconR galtanR if cntryrr==1  ,  type(linear) fe(country year) cl(country) dlabel("m.dom 789") xlabel("Ec. position of SDPs")
*graph save "h2", replace

interflex gendergappfl  manseg  lreconL galtanL lreconR galtanR if cntryrr==1 &lreconL<5 ,  type(linear) fe(country year) cl(country) ///
dlabel("m.dom 789") xlabel("Ec. position of SDPs")
graph save "h2_no outlier", replace

/*SUBSTANTIVE EFFECT*/
reg gendergappfl   c.manseg##c.lreconL  galtanL lreconR galtanR     i.country i.year if cntryrr==1  

sum manseg if cntryrr==1 & lreconL!=. & lreconL<5 /*sd=.1527 , mean=.36  */
sum lreconL if cntryrr==1 & manseg!=. & lreconL<5  /*sd=  .77 , mean=  3.01   */
/*MARGIN OF ONE SD ABOVE THE MEAND AND BELOW IT ON BOTH MANSEG AND LRECONL*/
margin , atmeans at(manseg= (0.207 0.512)  lreconL=(2.24 3.78)) /*results are reported in the paper. a shift in the economic position of SDPs toward the center from one standard deviation below the mean to one standard deviation above it is associated with a decline of 8.2 percentage points in the gender gap in support for SDPs.*/
marginsplot

/* Table 2, Model 4: DISTANCE BETWEEN ECONOMIC POSITION OF RR and LEFT*/
reg gendergappfl  c.manseg##c.econdistance  galtanL galtanR   i.year i.country 
outreg2 using TableH.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +)

/* Table 2, Model 5: ECONOMIC POSITION OF THE RADICAL RIGHT*/
reg gendergappfl  c.manseg##c.lreconR  lreconL galtanR i.year i.country  
outreg2 using TableH.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 


interflex gendergappfl  manseg econdistance galtanL galtanR   if cntryrr==1 ,  type(linear) fe(country year) ///
dlabel("male dom. manual sectors") xlabel("Distance between economic position of FRPs and SDPs") title("H3") yrange( -1.1 .5)   
graph save "h3", replace
*graph combine "h2 with galtan" "h3",  ycommon 
graph combine "h2_no outlier" "h3",  ycommon 
graph save "Figure 4"  


***************************************
*** Analyses in the Online Appendix ***
***************************************

/*Table D2(APPENDIX)*/

/*EXCLUDING SOUTHERN EUROPEAN COUNRIES*/

reg gendergappfl   c.manseg##c.lreconL galtanL lreconR galtanR i.year   i.country if cntryrr==1 & cntry!="ES" & cntry!="PT" & cntry!="GR"& cntry!="IT"
outreg2 using TableD.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

reg gendergappfl  c.manseg##c.econdistance  galtanL galtanR   i.year i.country if (cntry!="ES" & cntry!="PT" & cntry!="GR"& cntry!="IT")
outreg2 using TableD.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

/*EXCLUDING MAJORITARIAN COUNRIES*/
reg gendergappfl   c.manseg##c.lreconL galtanL lreconR galtanR i.year   i.country if cntryrr==1 &  cntry!="GB" & & cntry!="FR"
outreg2 using TableD.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

reg gendergappfl  c.manseg##c.econdistance  galtanL galtanR   i.year i.country if   cntry!="GB" & cntry!="IE"& cntry!="FR"
outreg2 using TableD.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

log close